/*
 * Killocan 2014
 * http://killocan.blogspot.com
*/

#include <allegro.h>

#include "energybar.h"

Player * EnergyBar::m_player = NULL;

void EnergyBar::drawEnerybar(BITMAP * buffer, int x, int y, mm_weapons::WEAPONS weapon)
{
	rectfill(buffer, x, y, x+15, y+111, 0);
  x+=2;

  int color1, color2;
  color1=color2=0;

  switch(weapon)
  {
    case mm_weapons::W_MEGA_BUSTER:
      color1 = 0xFCE4A0;
      color2 = 0XFFFFFF;
    break;
    case mm_weapons::W_PLATFORM_CREATOR:
      color1 = 0x0080C0;
      color2 = 0x00FFFF;
    break;
    case mm_weapons::W_CUTMAN_GUN:
      color1 = 0x808080;
      color2 = 0xFFFFFF;
    break;
    case mm_weapons::W_GUTSMAN_GUN:
      color1 = 0xE06000;
      color2 = 0xFFFFFF;
    break;
    case mm_weapons::W_ICEMAN_GUN: 
      color1 = 0x0060C0;
      color2 = 0xFFFFFF;
    break;
    case mm_weapons::W_BOMBMAN_GUN: 
      color1 = 0x00C000;
      color2 = 0xFFFFFF;
    break;
    case mm_weapons::W_FIREMAN_GUN: 
      color1 = 0xE04000;
      color2 = 0xE0C000;
    break;
    case mm_weapons::W_ELECMAN_GUN:
      color1 = 0x808080;
      color2 = 0xE0E080;
    break;
    default:
    break;
  }

  int weaponEnergy = (weapon == mm_weapons::W_MEGA_BUSTER) ? m_player->life : m_player->weapons[weapon];

  int ybottom = y+112;
  for (int i = 0; i < weaponEnergy; ++i)
  {
  	ybottom -= 4;
    rectfill(buffer, x,   ybottom, x+11, ybottom+1, color1);
    rectfill(buffer, x+4, ybottom, x+7,  ybottom+1, color2);
  }
}
